<template>
  <div class="login">
    <input type="text" name="" id="username" v-model="username">
    <button @click="handleBtnClick">进入聊天室</button>
  </div>
</template>

<script>

export default {
  name: 'Login',
  data() {
    return {
      username: '',

    }
  },
  methods: {
    handleBtnClick() {
      if(!this.username.trim().length) {
        return;
      }
      localStorage.setItem('username', this.username);

      this.$router.push('/');
    }
  }
}
</script>

